# -*- coding: utf-8 -*-
#
# File: Instrumento.py
#
# Copyright (c) 2006 by IBICT
# Generator: ArchGenXML Version 1.5.0
#            http://plone.org/products/archgenxml
#
# GNU General Public License (GPL)
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
#

__author__ = """IBICT <cadu@ibict.br>"""
__docformat__ = 'plaintext'

from AccessControl import ClassSecurityInfo
from Products.Archetypes.atapi import *
from Products.Archetypes.SQLStorage import *
from Products.SIGFS.config import *

# additional imports from tagged value 'import'
from Products.SIGFS.Widgets import MonetaryWidget

##code-section module-header #fill in your manual code here
from Products.CMFCore.utils import getToolByName
##/code-section module-header

schema = Schema((

    StringField(
        name='numero',
        widget=StringWidget(
            label="Número",
            description="Informe o número que identifica o Instrumento.",
            label_msgid='SIGFS_label_numero',
            description_msgid='SIGFS_help_numero',
            i18n_domain='SIGFS',
        ),
        serchable="1",
        required=1,
        accessor="Id"
    ),

    FloatField(
        name='valor',
        serchable="1",
        required=1,
        widget=MonetaryWidget(
            label="Valor do Instrumento",
            description="Informe qual será o valor do Instrumento.",
            label_msgid='SIGFS_label_valor',
            description_msgid='SIGFS_help_valor',
            i18n_domain='SIGFS',
        )
    ),

    TextField(
        name='observacao',
        serchable="1",
        widget=TextAreaWidget(
            label="Observação",
            description="Se o Instrumento possui alguma observação, por favor informe-a aqui.",
            label_msgid='SIGFS_label_observacao',
            description_msgid='SIGFS_help_observacao',
            i18n_domain='SIGFS',
        )
    ),

    TextField(
        name='descricao_instrumento',
        allowable_content_types=('text/plain', 'text/structured', 'text/html', 'application/msword',),
        serchable="1",
        default_output_type='text/html',
        widget=RichWidget(
            label="Descrição",
            description="Informe a descrição para o Instrumento.",
            label_msgid='SIGFS_label_descricao_instrumento',
            description_msgid='SIGFS_help_descricao_instrumento',
            i18n_domain='SIGFS',
        ),
        required=1
    ),

    StringField(
        name='estado_workflow',
        serchable="1",
        enforceVocabulary=1,
        widget=SelectionWidget(
            label="Estado do Instrumento",
            description="Informe qual é o estado em que se encontra o Instrumento quando na agência. Este item será de responsabilidade da Agência.",
            format="select",
            label_msgid='SIGFS_label_estado_workflow',
            description_msgid='SIGFS_help_estado_workflow',
            i18n_domain='SIGFS',
        ),
        vocabulary='getEstadosWorkflow'
    ),

    DateTimeField(
        name='data_vigencia',
        default="DateTime()",
        serchable="1",
        widget=CalendarWidget(
            label="Data de vigência",
            description="Informe a data limite de envio de propostas.",
            format="%d/%m/%Y",
            date_only="1",
            show_hm=False,
            label_msgid='SIGFS_label_data_vigencia',
            description_msgid='SIGFS_help_data_vigencia',
            i18n_domain='SIGFS',
        )
    ),

    DateTimeField(
        name='data_vigencia_prorrogacao',
        default="DateTime()",
        serchable="1",
        widget=CalendarWidget(
            label="Prorrogação da data de vigência",
            description="Se houve prorrogação na data de vigência da Chamada Pública, informe aqui.",
            format="%d/%m/%Y",
            date_only="1",
            show_hm=False,
            label_msgid='SIGFS_label_data_vigencia_prorrogacao',
            description_msgid='SIGFS_help_data_vigencia_prorrogacao',
            i18n_domain='SIGFS',
        )
    ),

    DateTimeField(
        name='data_merito',
        default="DateTime()",
        serchable="1",
        widget=CalendarWidget(
            label="Data de mérito",
            description="Informe a data de avaliação de mérito.",
            format="%d/%m/%Y",
            date_only="1",
            show_hm=False,
            label_msgid='SIGFS_label_data_merito',
            description_msgid='SIGFS_help_data_merito',
            i18n_domain='SIGFS',
        )
    ),

    DateTimeField(
        name='data_merito_prorrogacao',
        default="DateTime()",
        serchable="1",
        widget=CalendarWidget(
            label="Prorrogação da data de mérito",
            description="Se houve prorrogação na data de mérito, informe aqui.",
            format="%d/%m/%Y",
            date_only="1",
            show_hm=False,
            label_msgid='SIGFS_label_data_merito_prorrogacao',
            description_msgid='SIGFS_help_data_merito_prorrogacao',
            i18n_domain='SIGFS',
        )
    ),

    DateTimeField(
        name='data_divulgacao',
        default="DateTime()",
        serchable="1",
        widget=CalendarWidget(
            label="Data de divulgação",
            description="Informe a data de divulgação do resultado da Chamada Pública.",
            format="%d/%m/%Y",
            date_only="1",
            show_hm=False,
            label_msgid='SIGFS_label_data_divulgacao',
            description_msgid='SIGFS_help_data_divulgacao',
            i18n_domain='SIGFS',
        )
    ),

    DateTimeField(
        name='data_divulgacao_prorrogacao',
        default="DateTime()",
        serchable="1",
        widget=CalendarWidget(
            label="Prorrogação da data de divulgação",
            description="Se houve prorrogação na data de divulgação da Chamada Pública, informe aqui.",
            format="%d/%m/%Y",
            date_only="1",
            show_hm=False,
            label_msgid='SIGFS_label_data_divulgacao_prorrogacao',
            description_msgid='SIGFS_help_data_divulgacao_prorrogacao',
            i18n_domain='SIGFS',
        )
    ),

),
)

##code-section after-local-schema #fill in your manual code here
##/code-section after-local-schema

Instrumento_schema = schema.copy()

##code-section after-schema #fill in your manual code here
##/code-section after-schema

class Instrumento:
    """
    """
    security = ClassSecurityInfo()

    allowed_content_types = ['Aditivo']
    _at_rename_after_creation = True

    schema = Instrumento_schema

    ##code-section class-header #fill in your manual code here
    ##/code-section class-header

    # Methods

    # Manually created methods

    def getEstadosWorkflow(self):
        """Retorna a lista de Estados de workflow do Instrumento."""
        portal_sigfs = getToolByName(self, 'portal_sigfs')
        result = []
        vocabulary = portal_sigfs.getVocab_estado_workflow()

        for item in vocabulary:
            parts = item.split(';')
            result.append([parts[0], parts[1]])
        return DisplayList(tuple(result))


# end of class Instrumento

##code-section module-footer #fill in your manual code here
##/code-section module-footer



